package com.tengju.support.domain.model.star;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import org.springframework.util.StringUtils;

@AllArgsConstructor
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum StarIndicatorType {

    MANAGE_DEALER_NUM("Manage_Dealer_Num", "管理过的经销商人数"),
    CUSTOMER_MEMBERS_NUM("Customer_Members_Num","直属客户数(不含注册用户)"),
    DEVELOP_DEALER_NUM("Develop_Dealer_Num","培养过的经销商人数"),
    DEVELOP_CITY_SERVICE_NUM("Develop_City_Sevicer_Num","培养过城市服务商人数"),
    DEVELOP_SEC_NUM("Develop_Sec_Num","培养过sec人数"),
    RECENT_AVG_PROFIT("Recent_Avg_Profit","最近两个月服务费的平均值(1号上月和上上月平均,2号本月与上月平均)"),
    RECENT_TWO_MONTHS_AVG_ACHIEVEMENT("Recent_Two_Months_Avg_Achievement","最近2月销售额平均值(1号上月,2号及以后本月)"),
    ;

    private String code;
    private String desc;

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static StarIndicatorType fromVal(String code) {

        if (StringUtils.isEmpty(code)) {
            return null;
        }

        for (StarIndicatorType type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        return null;
    }

    public static StarIndicatorType fromName(String name) {
        for (StarIndicatorType type : values()) {
            if (type.name().equals(name)) {
                return type;
            }
        }
        return null;
    }



}
